part of 'page.dart';

class _IntroPageWloc extends StatelessWloc<IntroPage> with SingleTickerProviderStateMixin {
  late final bloc.IntroPageBloc _bloc;

  late final TabController tabController;

  void onFinishButtonPressed() {
    _bloc.requestIntroFinish();
  }

  void _onTabControllerChanged() {
    if (tabController.previousIndex == 0 && tabController.index == 1) {
      _bloc.requestIntroWelcomePass();
    }
  }

  @override
  void initState() {
    super.initState();

    _bloc = bloc.IntroPageBloc(
      userInfoBloc: core_di.sl(),
      rootNavigatorBloc: core_di.sl(),
      analyticsBloc: core_di.sl(),
      initialize: intro_page_di.sl(),
      finishIntro: intro_page_di.sl(),
      passIntroWelcome: intro_page_di.sl(),
    );

    tabController = TabController(
      initialIndex: 0,
      length: 2,
      vsync: this,
    );

    tabController.addListener(_onTabControllerChanged);
  }

  @override
  void dispose() {
    _bloc.close();
    tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return _IntroPageView(
      wloc: this,
    );
  }
}
